/*
 * @Author: ૮₍ ˙О˙₎ა
 * @Date: 2023-04-30 22:41:40
 */
import { ajax } from './ajax.js';
let btn=document.querySelector('.submit');
let inputs=document.querySelectorAll('input');
let h=document.querySelector('.error')
btn.onclick=function(e){
    let userName=inputs[0].value;
    let pwd=inputs[1].value;
    ajax.post('http://localhost/login',{userName,pwd},function(res){
    if(res.code==='0'){
            h.style.color='red'
            h.style.marginTop=-90+'px';
            h.style.display='block';
            h.innerHTML='用户不存在或密码错误'
        }else{
            window.location.assign('/index')
        }
    
    })

    e.preventDefault()
}